<?php
/**
 * 报价单详情模型
 */

namespace app\common\model;

use think\model\concern\SoftDelete;

class OfferDetail extends CommonBaseModel {
	use SoftDelete;
	// 自定义选择数据

	protected $name = 'offer_detail';
	protected $autoWriteTimestamp = true;

	// 可搜索字段
	public array $searchField = ['name'];

	// 可作为条件的字段
	public array $whereField = ['offer_id', 'school_id'];

	// 可作为多选条件的字段
	public array $multiWhereField = [];

	// 可做为时间
	public array $timeField = ['send_time'];
	protected $json = ['detail'];
	protected $jsonAssoc = true;
	/**
	 * 状态获取器
	 */
	public function getStatusTextAttr($value, $data): string {
		return self::BOOLEAN_TEXT[$data['status']];
	}
	public function getSendTimeAttr($value) {
		return date('Y-m-d', $value);
	}

/**
 * 配送时间修改器
 */
	public function setSendTimeAttr($value) {
		return strtotime($value);
	}
	/**
	 * 关联
	 */
	public function offer() {
		return $this->belongsTo(Offer::class);
	}/**
	 * 关联
	 */
	public function school() {
		return $this->belongsTo(School::class);
	}

}
